dojo.provide('app.form.Textarea')
dojo.require('dijit.form.Textarea')

dojo.declare('app.form.Textarea',[dijit.form.Textarea],{
	templateString: "<div><textarea ${!nameAttrSetting} dojoAttachPoint='focusNode,containerNode,textbox' autocomplete='off'></textarea><div>",
	placeholder:'',
	buildRendering:function(){
		this.inherited(arguments);
		this.textbox = this.srcNodeRef;
	},
	_setPlaceHolderAttr: function(v){
		this.placeHolder = v;
		if(!this._phspan){
			this._attachPoints.push('_phspan');
			/* dijitInputField class gives placeHolder same padding as the input field
			 * parent node already has dijitInputField class but it doesn't affect this <span>
			 * since it's position: absolute.
			 */
			this._phspan = dojo.create('span',{className:'dijitPlaceHolder dijitInputField'},this.textbox,'after');
		}
		this._phspan.innerHTML="";
		this._phspan.appendChild(document.createTextNode(v));
		
		this._updatePlaceHolder();
	},
	
	_updatePlaceHolder: function(){
		if(this._phspan){
			this._phspan.style.display=(this.placeHolder&&!this._focused&&!this.textbox.value)?"":"none";
		}
	}
})
